package com.gsj.boot.controller;

/**
 * @program: mybatisDriud
 * @description:
 * @author: 郭书江
 * @create: 2022-06-29 09:20
 **/

import com.gsj.boot.mapper.UserMapper;
import com.gsj.boot.model.User;
import com.gsj.boot.model.UserTb;
import com.gsj.boot.model.Users;
import com.gsj.boot.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j
@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private UserService userService;

    @GetMapping("/add")
    public Integer add(){
        User users = new User("1","李四","男");
        int insert = userService.insert(users);
        return insert;
    }
    @GetMapping("/get")
    public List<User> get(){
        long a = System.currentTimeMillis();
        List<User> all1 = userService.getAll();
        long b = System.currentTimeMillis();
        log.info("时间"+(b-a));
        return all1;
    }
    @GetMapping("/getBigData")
    public Integer getBigData(){
        long a = System.currentTimeMillis();
        List<UserTb> all1 = userService.getBigData();
        long b = System.currentTimeMillis();
        log.info("时间"+(b-a));
        return all1.size();
    }
    @GetMapping("/getOne")
    public User getOne(@RequestParam Long id){
        User all = userMapper.getOne(id);
        return all;
    }
    @GetMapping("/del")
    public Integer del(@RequestParam Long id){
        int delete = userService.delete(id);
        return delete;
    }
    @GetMapping("/selectUsers")
    public Users selectUsers(@RequestParam String key){
        return null;
    }
    @PostMapping
    public Integer update(@RequestParam String userName,@RequestParam String passWord){
        int update = userService.update(userName, passWord);
        return update;
    }


}

